package com.xjy.web.controller.controller;

import com.xjy.common.annotation.Log;
import com.xjy.common.core.controller.BaseController;
import com.xjy.common.core.domain.AjaxResult;
import com.xjy.common.core.page.TableDataInfo;
import com.xjy.common.enums.BusinessType;
import com.xjy.common.utils.poi.ExcelUtil;
import com.xjy.system.domain.bo.ReportProjFundQueryBo;
import com.xjy.system.domain.vo.ReportProjFundVo;
import com.xjy.system.service.IReportProjFundService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 资金情况Controller
 *
 * @author mlb
 * @date 2022-03-15
 */
@Api(value = "资金情况控制器", tags = {"资金情况管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/report_proj_fund")
public class ReportProjFundController extends BaseController {

    private final IReportProjFundService iReportProjFundService;

    /**
     * 查询资金情况列表
     */
    @ApiOperation("查询资金情况列表")
    @PreAuthorize("@ss.hasPermi('system:report_proj_fund:list')")
    @GetMapping("/list")
    public TableDataInfo<ReportProjFundVo> list(@Validated ReportProjFundQueryBo bo) {
        return iReportProjFundService.queryPageList(bo);
    }

    /**
     * 导出资金情况列表
     */
    @ApiOperation("导出资金情况列表")
    @PreAuthorize("@ss.hasPermi('system:report_proj_fund:export')")
    @Log(title = "资金情况", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<ReportProjFundVo> export(@Validated ReportProjFundQueryBo bo) {
        List<ReportProjFundVo> list = iReportProjFundService.queryList(bo);
        ExcelUtil<ReportProjFundVo> util = new ExcelUtil<ReportProjFundVo>(ReportProjFundVo.class);
        return util.exportExcel(list, "资金情况");
    }

    /**
     * 获取资金情况详细信息
     */
    @ApiOperation("获取资金情况详细信息")
    @PreAuthorize("@ss.hasPermi('system:report_proj_fund:query')")
    @GetMapping("/{projId}")
    public AjaxResult<ReportProjFundVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("projId") Long projId) {
        return AjaxResult.success(iReportProjFundService.queryById(projId));
    }

}
